home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12180 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  48 lines

  1. Path: ix.netcom.com!netnews
  2. From: jlilley@ix.netcom.com (John Lilley)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: What is name-mangling? (mentioned in FAQ)
  5. Date: 18 Mar 1996 18:20:21 GMT
  6. Organization: Netcom
  7. Distribution: world
  8. Message-ID: <4ik9h5$14k@reader2.ix.netcom.com>
  9. References: <4ik3s1$j7q@alcor.usc.edu>
  10. NNTP-Posting-Host: den-co8-14.ix.netcom.com
  11. Mime-Version: 1.0
  12. Content-Type: Text/Plain; charset=US-ASCII
  13. X-NETCOM-Date: Mon Mar 18 10:20:21 AM PST 1996
  14. X-Newsreader: WinVN 0.99.7
  15.  
  16. In article <4ik3s1$j7q@alcor.usc.edu>, wawda@alcor.usc.edu says...
  17. >
  18. >Hi. One of the questions in the FAQ mentioned "name-mangling". The
  19. >question was about compatibility between different vendor's libraires
  20. >with a common name-mangling scheme. But what is "name-mangling"?
  21. >Thanks in advance,
  22.  
  23.  
  24. "Name-mangling" is the means by which a C++ compiler distinguishes
  25. overloaded functions (or methods of different class with the same
  26. base name) from each other.  For example:
  27.  
  28. class A { void foo() {} };
  29. class B { void foo() {} };
  30. void foo() {}
  31. void foo(int x) {}
  32.  
  33. All of the foo's are distinct functions/methods and must not collide
  34. at link time, so the compiler maps them onto different names.  The
  35. strategies vary from a deterministic hash for linkers with short
  36. external name limits, to elaborate "decorating" schemes that embed
  37. the type information of the function and its arguments in a clever way.
  38. The latter is obviously advantageous in that the names can 
  39. be "unmangled" without the help of a separate table.
  40.  
  41. You can see these names by compiling the above code and looking at
  42. the resulting symbols via whatever utility is available (DUMPBIN
  43. for VC++, nm on UNIX, etc.)
  44.  
  45. john lilley
  46.  
  47.  
  48.